package xuanke;
import java.util.*;
public class Choice {
	
//选课
	public void Xuanke(Student stu,Course cour) {
		Scanner s = new Scanner(System.in);
		int CouNum = 5;
		System.out.println("请输入正确的课程编号进行选课！(可选五门课程)");
		for(int i=1;i<=5;i++) {
			
			System.out.println("请输入需选课的课程编号：");
			String n = s.next();
			stu.add(n, cour.out(n));
			CouNum = CouNum-1;
			System.out.println("选课成功,你还可以选 "+CouNum+" 门课！");
			
		}

    }
//退课:
	public void TuiKe(Student stu,Course cour) {
		Scanner s = new Scanner(System.in);
		System.out.println("是否需要进行退课！输入1进行退课，不需要则输入其它整数");
		int t1 = s.nextInt();
		if(t1==1) {
			System.out.println("请输入你需要退课的数量！");
			int t2 = s.nextInt();
			for(int i=1;i<=t2;i++) {
				System.out.println("请输入需要退课的正确编号进行退课!");
				String t3 = s.next();
				if(cour.courseInfo.containsKey(t3)) {
					
					stu.stuCourseInfo.remove(t3);
					System.out.println("退课成功");
					
				}
				else if(stu.stuCourseInfo.size()==5) {
					System.out.println("五门课已选完！");
					break;
				}
				else {
					System.out.println("该课未在你已选的课中！");
				}

			}
		}

	}
	
//退之后补选
	public void bxu(Student stu,Course cour) {
		Scanner s = new Scanner(System.in);
		int num = 5 - stu.stuCourseInfo.size();
		System.out.println("因你未选完五个课，你仍可选"+num+"门课,如需进行补选请输入1，退出请输入其他数字");
        int xuan = s.nextInt();
        if(xuan==1) {
        	for(int i=1;i<=num;i++) {
        		System.out.println("请输入需补选课的课程编号：");
        		String n = s.next();
        		stu.add(n, cour.out(n));
        	}
        }
        else {
        	System.out.println("已退出");
        }
	}
}

